| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
nkMaths::Vector Class Reference

A 4-component vector class, with floats. More...

## Public Member Functions
| Vector () noexcept
| Vector (float x, float y) noexcept
| Vector (float x, float y, float z) noexcept
| Vector (float x, float y, float z, float w) noexcept
| Vector (const Vector &other) noexcept
| Vector (const IntVector &other) noexcept
float | getLengthVec2 () const
float | getLengthVec3 () const
float | getLengthVec4 () const
float | getLengthSquaredVec2 () const
float | getLengthSquaredVec3 () const
float | getLengthSquaredVec4 () const
float | getDistanceVec2 (const Vector &other) const
float | getDistanceVec3 (const Vector &other) const
float | getDistanceVec4 (const Vector &other) const
float | getDistanceSquaredVec2 (const Vector &other) const
float | getDistanceSquaredVec3 (const Vector &other) const
float | getDistanceSquaredVec4 (const Vector &other) const
Vector & | normalizeVec2 ()
Vector & | normalizeVec3 ()
Vector & | normalizeVec4 ()
Vector | getNormalizedVec2 () const
Vector | getNormalizedVec3 () const
Vector | getNormalizedVec4 () const
float | dotProductVec2 (const Vector &other) const
float | dotProductVec3 (const Vector &other) const
float | dotProductVec4 (const Vector &other) const
Vector & | setAsCrossVec3 (const Vector &other)
Vector | getCrossVec3 (const Vector &other) const
nkMemory::String | toString () const
Vector & | fromString (nkMemory::StringView str)
Vector & | operator= (const Vector &other) noexcept
Vector & | operator= (const IntVector &other) noexcept
Vector | operator+ (const Vector &other) const
void | operator+= (const Vector &other)
Vector | operator- () const
Vector | operator- (const Vector &other) const
void | operator-= (const Vector &other)
Vector | operator* (const Vector &other) const
void | operator*= (const Vector &other)
Vector | operator* (const Quaternion &other) const
void | operator*= (const Quaternion &other)
Vector | operator* (const Matrix &mat) const
void | operator*= (const Matrix &other)
Vector | operator* (float coeff) const
void | operator*= (float coeff)
Vector | operator/ (const Vector &other) const
void | operator/= (const Vector &other)
Vector | operator/ (float coeff) const
void | operator/= (float coeff)
bool | operator== (const Vector &other) const
bool | operator!= (const Vector &other) const
bool | operator< (const Vector &other) const
bool | operator<= (const Vector &other) const
bool | operator> (const Vector &other) const
bool | operator>= (const Vector &other) const

## Static Public Member Functions
static float | distanceVec2 (const Vector &a, const Vector &b)
static float | distanceVec3 (const Vector &a, const Vector &b)
static float | distanceVec4 (const Vector &a, const Vector &b)
static float | distanceSquaredVec2 (const Vector &a, const Vector &b)
static float | distanceSquaredVec3 (const Vector &a, const Vector &b)
static float | distanceSquaredVec4 (const Vector &a, const Vector &b)
static float | dotVec2 (const Vector &a, const Vector &b)
static float | dotVec3 (const Vector &a, const Vector &b)
static float | dotVec4 (const Vector &a, const Vector &b)
static Vector | crossVec3 (const Vector &a, const Vector &b)

## Public Attributes
float | _x
| X component of the vector.
float | _y
| Y component of the vector.
float | _z
| Z component of the vector.
float | _w
| W component of the vector.

## Detailed Description

A 4-component vector class, with floats.

## Constructor & Destructor Documentation

## ◆ Vector() [1/6]

nkMaths::Vector::Vector | ( |  | ) |
| noexcept

Default constructor. Defaults all components to 0.

## ◆ Vector() [2/6]

nkMaths::Vector::Vector | ( | float | x,
|  | float | y
| ) |  |
| noexcept

2D constructor.

Parameters

  x | The x component to assign.
  y | The y component to assign.

Remarks
  The z component will be set to 0, while w will be set to 1.

## ◆ Vector() [3/6]

nkMaths::Vector::Vector | ( | float | x,
|  | float | y,
|  | float | z
| ) |  |
| noexcept

3D constructor.

Parameters

  x | The x component to assign.
  y | The y component to assign.
  z | The z component to assign.

Remarks
  The w component will be set to 1.

## ◆ Vector() [4/6]

nkMaths::Vector::Vector | ( | float | x,
|  | float | y,
|  | float | z,
|  | float | w
| ) |  |
| noexcept

4D constructor.

Parameters

  x | The x component to assign.
  y | The y component to assign.
  z | The z component to assign.
  w | The w component to assign.

## ◆ Vector() [5/6]

nkMaths::Vector::Vector | ( | const Vector & | other | ) |
| noexcept

Copy constructor.

Parameters

  other | The vector to copy from.

## ◆ Vector() [6/6]

nkMaths::Vector::Vector | ( | const IntVector & | other | ) |
| noexcept

Copy constructor.

Parameters

  other | The vector to copy from.

## Member Function Documentation

## ◆ getLengthVec2()

float nkMaths::Vector::getLengthVec2 | ( |  | ) | const

Returns
  The length of the vector, as if it was a 2D vector.

## ◆ getLengthVec3()

float nkMaths::Vector::getLengthVec3 | ( |  | ) | const

Returns
  The length of the vector, as if it was a 3D vector.

## ◆ getLengthVec4()

float nkMaths::Vector::getLengthVec4 | ( |  | ) | const

Returns
  The length of the vector, as if it was a 4D vector.

## ◆ getLengthSquaredVec2()

float nkMaths::Vector::getLengthSquaredVec2 | ( |  | ) | const

Returns
  The squared length of the vector as if it was a 2D vector.

Remarks
  For simple comparisons allowing it, prefer this function over the simple length as it is more performant.

## ◆ getLengthSquaredVec3()

float nkMaths::Vector::getLengthSquaredVec3 | ( |  | ) | const

Returns
  The squared length of the vector as if it was a 3D vector.

Remarks
  For simple comparisons allowing it, prefer this function over the simple length as it is more performant.

## ◆ getLengthSquaredVec4()

float nkMaths::Vector::getLengthSquaredVec4 | ( |  | ) | const

Returns
  The squared length of the vector as if it was a 4D vector.

Remarks
  For simple comparisons allowing it, prefer this function over the simple length as it is more performant.

## ◆ getDistanceVec2()

float nkMaths::Vector::getDistanceVec2 | ( | const Vector & | other | ) | const

Parameters

  other | The vector to check the distance with.

Returns
  The distance between both vectors, as if they were 2D vectors.

## ◆ getDistanceVec3()

float nkMaths::Vector::getDistanceVec3 | ( | const Vector & | other | ) | const

Parameters

  other | The vector to check the distance with.

Returns
  The distance between both vectors, as if they were 3D vectors.

## ◆ getDistanceVec4()

float nkMaths::Vector::getDistanceVec4 | ( | const Vector & | other | ) | const

Parameters

  other | The vector to check the distance with.

Returns
  The distance between both vectors, as if they were 4D vectors.

## ◆ getDistanceSquaredVec2()

float nkMaths::Vector::getDistanceSquaredVec2 | ( | const Vector & | other | ) | const

Parameters

  other | The vector to check the distance with.

Returns
  The squared distance between both vectors, as if they were 2D vectors.

Remarks
  For simple comparisons allowing it, prefer this function over the simple distance as it is more performant.

## ◆ getDistanceSquaredVec3()

float nkMaths::Vector::getDistanceSquaredVec3 | ( | const Vector & | other | ) | const

Parameters

  other | The vector to check the distance with.

Returns
  The squared distance between both vectors, as if they were 3D vectors.

Remarks
  For simple comparisons allowing it, prefer this function over the simple distance as it is more performant.

## ◆ getDistanceSquaredVec4()

float nkMaths::Vector::getDistanceSquaredVec4 | ( | const Vector & | other | ) | const

Parameters

  other | The vector to check the distance with.

Returns
  The squared distance between both vectors, as if they were 4D vectors.

Remarks
  For simple comparisons allowing it, prefer this function over the simple distance as it is more performant.

## ◆ normalizeVec2()

Vector& nkMaths::Vector::normalizeVec2 | ( |  | ) |

Normalizes the vector, interpreting it as a 2D vector.

Remarks
  The z and w components will be ignored.

## ◆ normalizeVec3()

Vector& nkMaths::Vector::normalizeVec3 | ( |  | ) |

Normalizes the vector, interpreting it as a 3D vector.

Remarks
  The w component will be ignored.

## ◆ normalizeVec4()

Vector& nkMaths::Vector::normalizeVec4 | ( |  | ) |

Normalizes the vector, interpreting it as a 4D vector.

## ◆ getNormalizedVec2()

Vector nkMaths::Vector::getNormalizedVec2 | ( |  | ) | const

Returns
  A vector corresponding to this vector interpreted as a 2D vector and normalized.

## ◆ getNormalizedVec3()

Vector nkMaths::Vector::getNormalizedVec3 | ( |  | ) | const

Returns
  A vector corresponding to this vector interpreted as a 3D vector and normalized.

## ◆ getNormalizedVec4()

Vector nkMaths::Vector::getNormalizedVec4 | ( |  | ) | const

Returns
  A vector corresponding to this vector interpreted as a 4D vector and normalized.

## ◆ dotProductVec2()

float nkMaths::Vector::dotProductVec2 | ( | const Vector & | other | ) | const

Computes the dot product, interpreting both vectors as 2D vectors.

Parameters

  other | The vector to compute the product with.

Returns
  The resulting dot product computed.

## ◆ dotProductVec3()

float nkMaths::Vector::dotProductVec3 | ( | const Vector & | other | ) | const

Computes the dot product, interpreting both vectors as 3D vectors.

Parameters

  other | The vector to compute the product with.

Returns
  The resulting dot product computed.

## ◆ dotProductVec4()

float nkMaths::Vector::dotProductVec4 | ( | const Vector & | other | ) | const

Computes the dot product, interpreting both vectors as 4D vectors.

Parameters

  other | The vector to compute the product with.

Returns
  The resulting dot product computed.

## ◆ setAsCrossVec3()

Vector& nkMaths::Vector::setAsCrossVec3 | ( | const Vector & | other | ) |

Computes and sets in place the cross product, interpreting both vectors as 3D vectors.

Parameters

  other | The vector to compute the product with.

## ◆ getCrossVec3()

Vector nkMaths::Vector::getCrossVec3 | ( | const Vector & | other | ) | const

Computes the cross product, interpreting both vectors as 3D vectors.

Parameters

  other | The vector to compute the product with.

Returns
  The resulting cross product computed.

## ◆ toString()

nkMemory::String nkMaths::Vector::toString | ( |  | ) | const

Returns
  The vector expressed as a string, formatted as "x, y, z, w".

## ◆ fromString()

Vector& nkMaths::Vector::fromString | ( | nkMemory::StringView | str | ) |

Parse components from a string. Format is "x,y,z,w".

Parameters

  str | The string to parse.

Returns
  The updated vector instance.

## ◆ operator=() [1/2]

Vector& nkMaths::Vector::operator= | ( | const Vector & | other | ) |
| noexcept

Assignment operator.

Parameters

  other | The vector to overwrite from.

Returns
  The calling vector, updated.

## ◆ operator=() [2/2]

Vector& nkMaths::Vector::operator= | ( | const IntVector & | other | ) |
| noexcept

Assignment operator.

Parameters

  other | The vector to overwrite from.

Returns
  The calling vector, updated.

## ◆ operator+()

Vector nkMaths::Vector::operator+ | ( | const Vector & | other | ) | const

Addition operator.

Parameters

  other | The vector to operate with.

Returns
  A result vector, after operation application.

## ◆ operator+=()

void nkMaths::Vector::operator+= | ( | const Vector & | other | ) |

Addition and assignment operator.

Parameters

  other | The vector to operate with.

## ◆ operator-() [1/2]

Vector nkMaths::Vector::operator- | ( |  | ) | const

Negation operator.

Returns
  A result vector, with all its members negated.

## ◆ operator-() [2/2]

Vector nkMaths::Vector::operator- | ( | const Vector & | other | ) | const

Subtraction operator.

Parameters

  other | The vector to operate with.

Returns
  A result vector, after operation application.

## ◆ operator-=()

void nkMaths::Vector::operator-= | ( | const Vector & | other | ) |

Subtraction and assignment operator.

Parameters

  other | The vector to operate with.

## ◆ operator*() [1/4]

Vector nkMaths::Vector::operator* | ( | const Vector & | other | ) | const

Multiplication operator.

Parameters

  other | The vector to operate with.

Returns
  A result vector, after operation application.

## ◆ operator*=() [1/4]

void nkMaths::Vector::operator*= | ( | const Vector & | other | ) |

Multiplication and assignment operator.

Parameters

  other | The vector to operate with.

## ◆ operator*() [2/4]

Vector nkMaths::Vector::operator* | ( | const Quaternion & | other | ) | const

Multiplication operator.

Parameters

  other | The quaternion to operate with.

Returns
  A result vector, after transformation.

## ◆ operator*=() [2/4]

void nkMaths::Vector::operator*= | ( | const Quaternion & | other | ) |

Multiplication and assignment operator.

Parameters

  other | The quaternion to operate with.

## ◆ operator*() [3/4]

Vector nkMaths::Vector::operator* | ( | const Matrix & | mat | ) | const

Multiplication operator.

Parameters

  mat | The matrix to operate with.

Returns
  A result vector, after transformation.

## ◆ operator*=() [3/4]

void nkMaths::Vector::operator*= | ( | const Matrix & | other | ) |

Multiplication and assignment operator.

Parameters

  other | The matrix to operate with.

## ◆ operator*() [4/4]

Vector nkMaths::Vector::operator* | ( | float | coeff | ) | const

Multiplication operator.

Parameters

  coeff | The scalar to operate with.

Returns
  A result vector, after operation application on all components.

## ◆ operator*=() [4/4]

void nkMaths::Vector::operator*= | ( | float | coeff | ) |

Multiplication and assignment operator.

Parameters

  coeff | The scalar to operate with.

## ◆ operator/() [1/2]

Vector nkMaths::Vector::operator/ | ( | const Vector & | other | ) | const

Division operator.

Parameters

  other | The vector to operate with.

Returns
  A result vector, after operation application.

## ◆ operator/=() [1/2]

void nkMaths::Vector::operator/= | ( | const Vector & | other | ) |

Division and assignment operator.

Parameters

  other | The vector to operate with.

## ◆ operator/() [2/2]

Vector nkMaths::Vector::operator/ | ( | float | coeff | ) | const

Division operator.

Parameters

  coeff | The scalar to operate with.

Returns
  A result vector, after operation application on all components.

## ◆ operator/=() [2/2]

void nkMaths::Vector::operator/= | ( | float | coeff | ) |

Division and assignment operator.

Parameters

  coeff | The scalar to operate with.

## ◆ operator==()

bool nkMaths::Vector::operator== | ( | const Vector & | other | ) | const

Equality operator.

Parameters

  other | The vector to check against.

Returns
  If the vectors are equal (true) or not (false).

## ◆ operator!=()

bool nkMaths::Vector::operator!= | ( | const Vector & | other | ) | const

Difference operator.

Parameters

  other | The vector to check against.

Returns
  If the vectors are different (true) or not (false).

## ◆ operator<()

bool nkMaths::Vector::operator< | ( | const Vector & | other | ) | const

Less than operator.

Parameters

  other | The vector to check against.

Returns
  If the calling vector is smaller (true) or not (false).

## ◆ operator<=()

bool nkMaths::Vector::operator<= | ( | const Vector & | other | ) | const

Less than or equal operator.

Parameters

  other | The vector to check against.

Returns
  If the calling vector is smaller, equal (true) or not (false).

## ◆ operator>()

bool nkMaths::Vector::operator> | ( | const Vector & | other | ) | const

Greater than operator.

Parameters

  other | The vector to check against.

Returns
  If the calling vector is greater (true) or not (false).

## ◆ operator>=()

bool nkMaths::Vector::operator>= | ( | const Vector & | other | ) | const

Greater than or equal operator.

Parameters

  other | The vector to check against.

Returns
  If the calling vector is greater, equal (true) or not (false).

## ◆ distanceVec2()

static float nkMaths::Vector::distanceVec2 | ( | const Vector & | a,
|  | const Vector & | b
| ) |  |
| static

Static version for a.getDistanceVec2(b).

Parameters

  a | The left operand.
  b | The right operand.

Returns
  The result of the operation.

## ◆ distanceVec3()

static float nkMaths::Vector::distanceVec3 | ( | const Vector & | a,
|  | const Vector & | b
| ) |  |
| static

Static version for a.getDistanceVec3(b).

Parameters

  a | The left operand.
  b | The right operand.

Returns
  The result of the operation.

## ◆ distanceVec4()

static float nkMaths::Vector::distanceVec4 | ( | const Vector & | a,
|  | const Vector & | b
| ) |  |
| static

Static version for a.getDistanceVec4(b).

Parameters

  a | The left operand.
  b | The right operand.

Returns
  The result of the operation.

## ◆ distanceSquaredVec2()

static float nkMaths::Vector::distanceSquaredVec2 | ( | const Vector & | a,
|  | const Vector & | b
| ) |  |
| static

Static version for a.getDistanceSquaredVec2(b).

Parameters

  a | The left operand.
  b | The right operand.

Returns
  The result of the operation.

## ◆ distanceSquaredVec3()

static float nkMaths::Vector::distanceSquaredVec3 | ( | const Vector & | a,
|  | const Vector & | b
| ) |  |
| static

Static version for a.getDistanceSquaredVec3(b).

Parameters

  a | The left operand.
  b | The right operand.

Returns
  The result of the operation.

## ◆ distanceSquaredVec4()

static float nkMaths::Vector::distanceSquaredVec4 | ( | const Vector & | a,
|  | const Vector & | b
| ) |  |
| static

Static version for a.getDistanceSquaredVec4(b).

Parameters

  a | The left operand.
  b | The right operand.

Returns
  The result of the operation.

## ◆ dotVec2()

static float nkMaths::Vector::dotVec2 | ( | const Vector & | a,
|  | const Vector & | b
| ) |  |
| static

Static version for a.dotProductVec2(b).

Parameters

  a | The left operand.
  b | The right operand.

Returns
  The result of the operation.

## ◆ dotVec3()

static float nkMaths::Vector::dotVec3 | ( | const Vector & | a,
|  | const Vector & | b
| ) |  |
| static

Static version for a.dotProductVec3(b).

Parameters

  a | The left operand.
  b | The right operand.

Returns
  The result of the operation.

## ◆ dotVec4()

static float nkMaths::Vector::dotVec4 | ( | const Vector & | a,
|  | const Vector & | b
| ) |  |
| static

Static version for a.dotProductVec3(b).

Parameters

  a | The left operand.
  b | The right operand.

Returns
  The result of the operation.

## ◆ crossVec3()

static Vector nkMaths::Vector::crossVec3 | ( | const Vector & | a,
|  | const Vector & | b
| ) |  |
| static

Static version for a.getCrossVec3(b).

Parameters

  a | The left operand.
  b | The right operand.

Returns
  The result of the operation.

The documentation for this class was generated from the following file:

- Documentation/Headers/NilkinsMaths/Algebra/Vector.h